GameMaker Studio 2 has a great many functions and variables related to getting the date and time and calculating other values based off of them. By default these functions return the local time as set by the system, but you can use the following function to switch between local and UTC time:
The rest of the date and time functions and variables are listed below:
The following built in variables can be used to get specific date and time components:
The following functions can be used to get specific date and time components, as well as for creating new ones or for getting the span of days/hours between two given dates etc...
- date_create_datetime
- date_current_datetime
- date_compare_date
- date_compare_datetime
- date_compare_time
- date_valid_datetime
- date_date_of
- date_time_of
- date_is_today
- date_leap_year
- date_date_string
- date_datetime_string
- date_time_string
- date_second_span
- date_minute_span
- date_hour_span
- date_day_span
- date_week_span
- date_month_span
- date_year_span
- date_days_in_month
- date_days_in_year
- date_get_second
- date_get_minute
- date_get_hour
- date_get_day
- date_get_weekday
- date_get_week
- date_get_month
- date_get_year
- date_get_second_of_year
- date_get_minute_of_year
- date_get_hour_of_year
- date_get_day_of_year
- date_inc_second
- date_inc_minute
- date_inc_hour
- date_inc_day
- date_inc_week
- date_inc_month
- date_inc_year
We also have two special time functions that give you a higher level of precision and control when running your game: